<?php
/**
 * This is a component to send email from CakePHP using PHPMailer
 * @link http://wiki.cakephp.org/tutorials:sending_email_with_phpmailer
 * @see http://wiki.cakephp.org/tutorials:sending_email
 */
 
class EmailComponent
{
/**
 * Send email using SMTP Auth by default.
 */
    var $from         = 'projekt.kariera@wp.pl'; 
    var $fromName     = "Projekt.Kariera Mailer";
    var $smtpUserName = 'projekt.kariera';  // SMTP username
    var	$smtpPassword = 'work44'; // SMTP password
    var $smtpHostNames= "smtp.wp.pl";  // specify main and backup server
    var $text_body = null;
    var $html_body = null;
    var $to = null;
    var $toName = null;
    var $subject = null;
    var $cc = null;
    var $bcc = null;
 
	var $controller;
 
	function startup( &$controller ) {
		$this->controller = &$controller;
	}
	
 /*
    function bodyText() {
	/** This is the body in plain text for non-HTML mail clients
	 *
        ob_start();
        $this->controller->render('email_body_plain');
        $mail = ob_get_clean();
        return $mail;
    }
/* 
    function bodyHTML() {
	/** This is HTML body text for HTML-enabled mail clients
	 *
        ob_start();
        $this->controller->render('email_body_html');
        $mail = ob_get_clean();
        return $mail;
    }
 
 */
    function send()
    {
		vendor('phpmailer'.DS.'class.phpmailer');
 
		$mail = new PHPMailer();
 
		$mail->IsSMTP();            // set mailer to use SMTP
		$mail->SMTPAuth = true;     // turn on SMTP authentication
		$mail->Host 	= $this->smtpHostNames;
		$mail->Username = $this->smtpUserName;
		$mail->Password = $this->smtpPassword;
 
		$mail->From     = $this->from;
		$mail->FromName = $this->fromName;
		$mail->AddAddress($this->to, $this->toName );
		$mail->AddReplyTo($this->from, $this->fromName );
 
		$mail->CharSet	= 'UTF-8';
		$mail->WordWrap = 50;                                 // set word wrap to 50 characters
		//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
		//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
		//$mail->IsHTML(false);                                  // set email format to HTML
 
		$mail->Subject = $this->subject;
		$mail->Body    = $this->text_body;
//		$mail->AltBody = 'test';//$this->bodyText();
 
		$success = $mail->Send();
 
       	return $success;
    }
 
}

?>